home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <graphics.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- int oldcolor;
- int y = 60;
- char buffer[80];
-
- /* Initialize the graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- outtextxy(10, 20, "Demonstrating getcolor");
- /* Get current color */
- oldcolor = getcolor();
- sprintf(buffer,"Current color: %d", oldcolor);
- outtextxy(10, 40, buffer);
- moveto(0,y);
- lineto(500,y);
- y += 40;
- /* Select a new color and verify by calling getcolor */
- setcolor(RED);
- sprintf(buffer,"New color: %d (should be 4)", getcolor());
- outtextxy(10, y-20, buffer);
- moveto(0,y);
- lineto(500,y);
- /* Restore previous color */
- setcolor(oldcolor);
- /* Give user a chance to see the result */
- outtextxy(10, y+60, "Hit any key to exit:");
- getch();
- closegraph(); /* Close graphics system */
- }